#ifndef __SCREEN_HPP
#define __SCREEN_HPP

#include "../../model/base/Graphic.hpp"
#include <iostream>
using namespace std;
namespace view { namespace base {
	
/**
 * 屏幕接口基类
 * @param GraphicPixelType 图形像素的类型
 */
template<class PixelType> class Screen {
	
	public:virtual void clear(void) = 0;
	public:virtual void fix(void)   = 0;
	public:virtual void scan(ostream& ost) const = 0;
	public:virtual void setPixel(const model::base::graphic::Pixel<PixelType>& gPixel) = 0;
	
	public:void setGraphic(const model::base::Graphic<PixelType>& graphic, int x = 0, int y = 0) {
		
		const model::base::graphic::Pixel<PixelType>* pixels = graphic.buff();
		model::base::graphic::Pixel<PixelType> p;
		
		for(unsigned i = 0, count = graphic.getPixelCount(); i < count; ++i) {
			p = pixels[i];
			
			p.setX(p.getX() + x);
			p.setY(p.getY() + y);
			
			setPixel(p);
		}
	}
	
	public:Screen& operator << (const model::base::Graphic<PixelType>& graphic) {
		setGraphic(graphic);
		return *this;
	}

	public:friend ostream& operator << (ostream& ost, const Screen& scr) {
		scr.scan(ost);
		return ost;
	}
};
};};

#endif
